import type { FlashSession } from '@/models/flashSession'
import type { CommonResult } from '@/models/request'
import request from '@/utils/request'

export function fetchList() {
  return request<CommonResult<FlashSession[]>>({
    url: '/flashSession/list',
    method: 'get',
  })
}

export function fetchSelectList(params: { flashPromotionId: number }) {
  return request<CommonResult<FlashSession[]>>({
    url: '/flashSession/selectList',
    method: 'get',
    params: params,
  })
}

export function updateStatus(params: { status?: number; id?: number }) {
  return request<CommonResult>({
    url: '/flashSession/update/status/' + params.id,
    method: 'post',
    params: params,
  })
}

export function deleteSession(id?: number) {
  return request<CommonResult>({
    url: '/flashSession/delete/' + id,
    method: 'post',
  })
}

export function createSession(data: FlashSession) {
  return request<CommonResult>({
    url: '/flashSession/create',
    method: 'post',
    data: data,
  })
}

export function updateSession(data: FlashSession) {
  return request<CommonResult>({
    url: '/flashSession/update/' + data.id,
    method: 'post',
    data: data,
  })
}
export function sessionDetail(id: number) {
  return request<CommonResult<FlashSession>>({
    url: '/flashSession/' + id,
    method: 'get',
  })
}
